/***************************************************************************
  A SymbolBrowser plugin for JuffEd editor.

  Copyright: 2010 Aleksander Sokoloff <asokol@mail.ru>


  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License.
  version 2 as published by the Free Software Foundation.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software Foundation,
  Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
***************************************************************************/


#ifndef SYMBOL_H
#define SYMBOL_H

#include <QObject>
#include <QString>
#include <QList>
#include <QIcon>
#include <QListIterator>

enum SymbolType
{
    SymbolTypeUnknown,
    SymbolTypeClass,
    SymbolTypeStruct,
    SymbolTypeNamespace,
    SymbolTypeFunc,
    SymbolTypePrototype
};


class SymbolInfo
{
public:
    explicit SymbolInfo(const SymbolType type = SymbolTypeUnknown, const QString &name = "");
    explicit SymbolInfo(const SymbolInfo *other);

    QString name() const { return mName; }
    QString detailedText() const { return mDetailedText; }
    int line() const { return mLine; }
    SymbolType type() const { return mType; }

protected:
    QString     mName;
    QString     mDetailedText;
    int         mLine;
    SymbolType  mType;
};


class Symbol: public SymbolInfo, public QList<Symbol *>
{
public:
    Symbol(const SymbolType type = SymbolTypeUnknown, const QString &name = "", Symbol *parent = NULL);
    virtual ~Symbol();

    void clear();

    void setName(const QString &name);
    void setDetailedText(const QString &text);
    void setLine(int line);
    void setSymbolType(SymbolType value);

    Symbol *parent() const { return mParent; }
    void setParent(Symbol *parent);

    Symbol *relatedSymbol() const { return mRelatedSymbol; }
    void setRelatedSymbol(Symbol *value);

    Symbol* find(const QString &name) const;
    Symbol* find(const QString &name, SymbolType type) const;

private:
    Symbol      *mParent;
    Symbol      *mRelatedSymbol;

};


//typedef QListIterator<const Symbol*>::QListIterator(const QList<const Symbol*>&) SymbolIt;
//QListIterator<const Symbol*>::QListIterator(const QListIterator<const Symbol*>&)
//typedef QListIterator<Symbol const*> SymbolIterator;
//typedef QMutableListIterator<Symbol *> SymbolMutableIterator;
typedef QList<Symbol *>::iterator  SymbolIterator;
#endif // SYMBOL_H
